
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	'id'=>'rule-form',
	'enableAjaxValidation'=>true,
)); ?>
<div class="alert alert-success" id="attId">
<?php echo DataHelper::getAttention(); ?>
</div>
<?php 
// Yii::app()->clientScript->registerScript('onRuleClassChanged',
// '
// 		$("#classInput").change(function(){
		
// 		var v = $(this).val();
// 		$.post("'.Yii::app()->createUrl("rule/getpropid").'",{ruleclass:'.v.'},function(result)
// 		{
// 		if(result != null)
// 			$("#RecId").html("Recommend Id: "+result);
// 		}
		
// 		)
// 		});
// '
//)
?>
<script>
function changeTo(content)
{
	$("#historyCode").html(unescape(content));
}
</script>
<div class="pull-right">
    <?php

//      array(
//                 array('label'=>'Action', 'url'=>'javascript:alert("aaa")'),
//                 array('label'=>'Another action', 'url'=>'#'),
//                 array('label'=>'Something else', 'url'=>'#'),
//             )
if(isset($itemArr)){
$this->widget('bootstrap.widgets.TbButtonGroup', array(
        'type'=>'primary', // '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
        'buttons'=>array(
            array('label'=>'View History Rules', 'items'=>$itemArr),
        ),
    )); 
}?>
</div>

<div class="alert alert-info" id="historyCode">
</div>
Sample Rule:
<div class="alert alert-success">
</div>
<?php echo $this->renderPartial('_recentHistory',array('rows'=>DataHelper::getRecentHistory($model->isNewRecord))); ?>
	<p class="help-block">Fields with <span class="required">*</span> are required.</p>
	<?php $this->widget('bootstrap.widgets.TbAlert'); ?>
	<?php echo $form->errorSummary($model); ?>

	<?php echo $form->textFieldRow($model,'gid',array('class'=>'span5','value'=>'1','readonly'=>true)); ?>

	
	<?php echo $form->textFieldRow($model,'sid',array('class'=>'span5')); ?>
	<?php $this->beginWidget('CTextHighlighter',array('showLineNumbers'=>true,'language'=>'php'));?>
	<?php echo $model->fullcontent?>
	<?php $this->endWidget();?>
	<?php echo $form->labelEx($model,'ruleClass');?>
	<?php $this->widget('bootstrap.widgets.TbTypeahead', array(
    'options'=>array(
		'source'=>DataHelper::getClassList(),
        'items'=>4,
        'matcher'=>"js:function(item) {
            return ~item.toLowerCase().indexOf(this.query.toLowerCase());
        }",
    ),
	'model'=>$model,
	'attribute'=>'ruleClass',
	'id'=>'classInput',
)); ?>
	<?php //echo $form->textFieldRow($model,'ruleClass',array('class'=>'span5','maxlength'=>60)); ?>
	<?php echo $form->textAreaRow($model,'fullcontent',array('rows'=>6, 'cols'=>50, 'class'=>'span8')); ?>

	<?php echo $form->textAreaRow($model,'rulecomment',array('rows'=>6, 'cols'=>50, 'class'=>'span8')); ?>
	
	<?php echo $form->labelEx($model,'categoryId');?>
	<?php echo $form->dropDownList($model,'categoryId',CHtml::listData(RuleCategory::model()->findAll(), "id", "category"),array('disabled'=>!$model->isNewRecord,'id'=>'catDrop'))?>
	<?php echo $form->textFieldRow($model,'revision',array('class'=>'span5','maxlength'=>10,'readonly'=>false)); ?>

	<div class="form-actions">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
			'label'=>$model->isNewRecord ? 'Create' : 'Save',
		)); ?>
	</div>

<?php $this->endWidget(); ?>